<template>
  <div>
    <span>设备Id：</span><el-input class="" v-model="deviceId"> </el-input>
    <span>关键词：</span><el-input class="" v-model="keyword"></el-input>

    <span>继电器：</span>
    <el-select v-model="index" placeholder="请选择">
      <el-option v-for="item in 16" :key="item" :label="item" :value="item">
      </el-option>
    </el-select>
    <el-switch
      v-model="value"
      inactive-value="0"
      active-value="1"
      active-color="#13ce66"
      inactive-color="#ff4949"
      @change="control"
    >
    </el-switch>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      deviceId: "16096064",
      keyword: "3596064",
      index: 0,
      value: "1",
    };
  },
  methods: {
    control() {
      console.log(this.deviceId, this.keyword, this.index, this.value);
      axios
        .post("/xkh/iotdevice/contr_com", {
          facId: this.deviceId,
          keyWord: this.keyword,
          sentParamReqzzVos: [
            {
              name: "relayNum",
              val: this.value,
            },
            {
              name: "relayIndex",
              val: this.index.toString(),
            },
          ],
        })
        .then((res) => {
          if (res.data.code === 200) alert("已发送，等待响应");
          else alert("控制失败，请检查参数");
        })
        .catch((err) => alert("控制失败，请检查网络" + err.message));
    },
  },
};
</script>

<style lang="scss">
</style>